/*
 * @Description: 基础告警管理
 */
import request from '@/utils/request'
export default {
    /**
     * @description: 获取告警模板表格 *代表必填
     * @param {String/Number} page *
     * @param {String/Number} size *
     */
    getlist(params) {
        return request.post("v3/alarm/baseAlarm/queryPageList", {
            ...params,
            entity: {
                organizationNo: sessionStorage.getItem("organizationNo"),
                farmingTypeNo: sessionStorage.getItem("farmingTypeNo"),
                system: "SC"
            }
        });
    },
    /**
     * @description: 添加
     * @param {Object}  *
     */
    addlist(params) {
        return request.post('v3/alarm/baseAlarm/add', {
            ...params,
            organizationNo: sessionStorage.getItem("organizationNo"),
            farmingTypeNo: sessionStorage.getItem("farmingTypeNo") || "暂无数据",
            "system": "SC"
        });
    },
    /**
     * @description: 批量删除
     * @param {Object}  *
     */
    delList(params) {
        return request.post('v3/alarm/baseAlarm/delList', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            'baseAlarmIdList': params
        });
    },
    /**
     * @description: 修改
     * @param {Object}  *
     */
    editlist(params) {
        return request.post('v3/alarm/baseAlarm/edit', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            ...params,
            "system": "SC"
        });
    },
    /**
     * @description: 条件查询
     * @param {Object}  *
     */
    querybycondition(params) {
        return request.post('v3/alarm/baseAlarm/queryByCondition', {
            ...params,
            organizationNo: sessionStorage.getItem("organizationNo"),
            "system": "SC"
        });
    },
    /**
     * @description: 获取可选择告警模板下拉数据
     * @param {Object}  *
     */
    getalarmTemplatelist() {
        return request.post('v3/alarm/alarmTemplate/queryByCondition', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            farmingTypeNo: sessionStorage.getItem("farmingTypeNo")
        });
    },
    /**
     * @description: 通过告警模板id获取详细数据
     * @param {Object}  *
     */
    getalarmTemplatemessagelist(alarmTemplateId) {
        return request.get(`v3/alarm/alarmTemplate/query?alarmTemplateId=${alarmTemplateId}`);
    },
    /**
     * @description: 获取批次可选择数据
     * @param {Object}  *
     */
    getbatchlist(params = {}) {
        return request.post('v3/batch/productionBatch/queryByCondition', {
            farmingTypeNo: sessionStorage.getItem("farmingTypeNo"),
            organizationNo: sessionStorage.getItem("organizationNo"),
            ...params
            // org
        });
    },
    /**
     * @description: 查询所有数据类别
     * @param {Object}  *
     */
    getalldatalist() {
        return request.get('v3/iot/dataTypeConfig/queryAllDataType');
    },
    /**
     * @description: 条件查询告警类型
     * @param {Object}  *
     */
    getalarmTypelist(dataTypeId) {
        let data = { dataTypeId }
        return request.post('v3/alarm/alarmTypeDataTypeMapper/queryByCondition', dataTypeId ? data : {});
    },
    /**
     * @description: 告警联系人信息
     * @param {Object}  *
     */
    getalarmCharge(alarmContactId) {
        return request.get(`v3/alarm/alarmContact/query/${alarmContactId}`);
    },
    /**
     * @description: 获取监测数据项
     * @param {Object}  *
     */
    getdataitemlist(params) {
        return request.post('v3/iot/dataItem/queryByCondition', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            deleteFlag: false,
            visible: true,
            ...params
        });
    },
    // ----下面是数值告警相关----
    /**
     * @description: 数值告警添加
     * @param {Object}  *
     */
    addDataItem(params) {
        return request.post('v3/alarm/numericalAlarm/add', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            ...params
        });
    },
    /**
     * @description: 数值告警删除
     * @param {Object}  *
     */
    delDataItem(params) {
        return request.post('v3/alarm/numericalAlarm/delList', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            numericalAlarmIdList: params
        })
    },
    /**
     * @description: 数值告警修改
     * @param {Object}  *
     */
    editDataItem(params) {
        return request.post('v3/alarm/numericalAlarm/edit', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            ...params
        })
    },
    /**
     * @description: 数值告警表格查询
     * @param {Object}  *
     */
    getDataItemtable(params) {
        return request.post('v3/alarm/numericalAlarm/queryPageList', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            ...params
        })
    },
    /**
     * @description: 数值告警条件查询
     * @param {Object}  *
     */
    querybycondDataItem(params) {
        return request.post('v3/alarm/numericalAlarm/queryByCondition', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            ...params
        })
    },
    /**
     * @description: 获取设施下拉数据
     * @param {Object}  *
     */
    queryfacility(params) {
        return request.post('v3/alarm/numericalAlarm/queryByCondition', {
            organizationNo: sessionStorage.getItem("organizationNo"),
            ...params
        })
    }
};
